<?php

class Default_Model_DbTable_Contact extends Zend_Db_Table_Abstract
{

    protected $_name = 'contact';
    
    public function Add($oid , $name , $phone , $email , $desc , $add , $cdate , $detail , $stt){
    	$data = array(
    				"OBJECT_ID" => $oid,
    				"NAME" => $name,
    				"PHONE" =>$phone,
	    			"EMAIL" => $email,
	    			"DESCRIPTION" => $desc,
	    			"ADDRESS" => $desc,
	    			"CREATEDATE" => $cdate,
	    			"DETAIL" => $detail,
	    			"STATUS" => $stt
    			);
    	
    	return $this->insert($data);
    }
    
    public function Update($id , $oid , $name , $phone , $email , $desc , $add , $cdate , $detail , $stt){
    	$data = array(
    			"OBJECT_ID" => $oid,
    			"NAME" => $name,
    			"PHONE" =>$phone,
    			"EMAIL" => $email,
    			"DESCRIPTION" => $desc,
    			"ADDRESS" => $desc,
    			"CREATEDATE" => $cdate,
    			"DETAIL" => $detail,
    			"STATUS" => $stt
    	);
    	
    	return $this->update($data, "ID = $id");
    }
    
    public function Delete($id){
    	return $this->Delete($id);
    }
    
    public function GetAll(){
    	$select = $this->select( Zend_Db_Table::SELECT_WITH_FROM_PART )->setIntegrityCheck(false);
    	
    	$select->from("contact as c",array(
	    			"NAME",
	    			"PHONE",
	    			"EMAIL",
	    			"DESCRIPTION",
	    			"ADDRESS",
	    			"CREATEDATE",
	    			"DETAIL",
	    			"STATUS"
    			))->joinLeft("object as o", "o.ID = c.OBJECT_ID",array("OBJECT_NAME"))
    	->group("o.ID");
    	return $this->fetchAll($select)->toArray();
    }
    
    public function GetById($id){
    	
    }
    
    public function Active($id){
    	
    }


}

